/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package controllers;

import entities.User;
import java.util.ArrayList;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Alberto, Alessandra
 */
@Stateless
public class SearchManager {
    
    @PersistenceContext
    EntityManager em;
    
    public ArrayList<User> search (String username) {
        ArrayList<User> users = new ArrayList<>();
        users.addAll(em.createNamedQuery("searchByUsername", User.class)
                .setParameter("Uusername", username + "%").getResultList());
        return users;
    }
    
}
